package org.tea.inventory.admin.web.admin;

import java.util.Map;

import javax.annotation.Resource;

import org.tea.inventory.admin.annotation.LoginAdmin;
import org.tea.inventory.base.util.ResponseUtil;
import org.tea.inventory.db.service.UserMessageService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/message")
public class UserMessageController {
	private final Log logger = LogFactory.getLog(UserMessageController.class);

	@Resource UserMessageService messageService;
	
	@RequestMapping("list")
	public Object list (@LoginAdmin Integer adminId,
			String id,
			@RequestParam(value = "page", defaultValue = "1") Integer page,
			@RequestParam(value = "limit", defaultValue = "10") Integer limit,
			String sort, String order){
		if(adminId == null || id == null)
			return ResponseUtil.fail401();
		Map<String, Object> data = messageService.findUserMessageList(id, page, limit, sort, order);
		return ResponseUtil.ok(data);
	}
}
